package net.xdclass.xdclasssky.controller;

import net.xdclass.xdclasssky.model.AlarmMessage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 小滴课堂,愿景：让技术不再难学
 *
 * @Description
 * @Author 二当家小D，微信：xdclass6
 * @Remark 有问题直接联系我，源码-笔记-技术交流群
 * @Version 1.0
 **/

@RestController
public class CallbackController {

    private List<AlarmMessage> messageList = new ArrayList<>();


    @PostMapping("webhook")
    public void webhook(@RequestBody List<AlarmMessage> alarmMessageList){

        System.out.println("收到消息："+alarmMessageList);

        messageList.addAll(alarmMessageList);
    }

    @GetMapping("list_alarm_msg")
    public List<AlarmMessage> list(){

        return messageList;
    }


}
